package com.td.module.agro.dal.mysql.input;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.agro.controller.admin.input.vo.InputExportReqVO;
import com.td.module.agro.controller.admin.input.vo.InputPageReqVO;
import com.td.module.agro.dal.dataobject.input.InputDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 投入品 Mapper
 *
 * @author 吴佰强
 */
@Mapper
public interface InputMapper extends BaseMapperX<InputDO> {

    default PageResult<InputDO> selectPage(InputPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InputDO>()
                .likeIfPresent(InputDO::getInputName, reqVO.getInputName())
                .eqIfPresent(InputDO::getInputType, reqVO.getInputType())
                .eqIfPresent(InputDO::getInputDescribe, reqVO.getInputDescribe())
                .eqIfPresent(InputDO::getInputPrice, reqVO.getInputPrice())
                .betweenIfPresent(InputDO::getInputTime, reqVO.getInputTime())
                .betweenIfPresent(InputDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InputDO::getId));
    }

    default List<InputDO> selectList(InputExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InputDO>()
                .likeIfPresent(InputDO::getInputName, reqVO.getInputName())
                .eqIfPresent(InputDO::getInputType, reqVO.getInputType())
                .eqIfPresent(InputDO::getInputDescribe, reqVO.getInputDescribe())
                .eqIfPresent(InputDO::getInputPrice, reqVO.getInputPrice())
                .betweenIfPresent(InputDO::getInputTime, reqVO.getInputTime())
                .betweenIfPresent(InputDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(InputDO::getId));
    }

}
